package com.bxd.baodan.fragment;

import android.os.Bundle;
import android.text.Editable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.RadioGroup;

import com.bxd.baodan.R;
import com.bxd.baodan.util.LogUtil;
import com.bxd.baodan.widget.MyTextWatcher;

/**
 *
 */

public class AgeAndSexFragment extends BaseStepFragment {
    private RadioGroup genderRg;
    private EditText age_et;
    private String age;
    private String preAge;
    private View view;



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
LogUtil.e("AgeAndSexFragment: ----CreateView");
        view = inflater.inflate(R.layout.step_1_sex_name, null);

        init(view);
        return view;
    }

    private void init(View view) {


        genderRg = (RadioGroup) view.findViewById(R.id.sex_rg);
        age_et = (EditText) view.findViewById(R.id.age);



        genderRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.man) {
                    getDesignStep().gender = "male";
                } else if (checkedId == R.id.woman) {
                    getDesignStep().gender = "female";
                }
            }
        });




        age_et.addTextChangedListener(new MyTextWatcher() {


            @Override
            public void afterTextChanged(Editable s) {

                age = age_et.getText().toString();
                getDesignStep().age = age;

            }
        });
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
       super.onViewCreated(view, savedInstanceState);

        title.setText(roleText +"的基本信息" );
        title1.setText(roleText +"的性别" );
        title2.setText(roleText +"的年龄" );





    }

    @Override
    public void onDestroyView() {
        LogUtil.e("AgeAndSexFragment------: onDestroyView");
        super.onDestroyView();
    }
}
